package com.newjiabo.web.controller.ski;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.newjiabo.common.annotation.RepeatSubmit;
import com.newjiabo.ski.domain.SkiMoreServices;
import com.newjiabo.ski.domain.dto.MoreServicesDTO;
import com.newjiabo.ski.domain.dto.SkiSnowFieldDTO;
import com.newjiabo.ski.service.ISkiMoreServicesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.newjiabo.common.annotation.Log;
import com.newjiabo.common.core.controller.BaseController;
import com.newjiabo.common.core.domain.AjaxResult;
import com.newjiabo.common.enums.BusinessType;
import com.newjiabo.common.utils.poi.ExcelUtil;
import com.newjiabo.common.core.page.TableDataInfo;

/**
 * 更多服务Controller
 *
 * @author CaoMengHui
 * @date 2023-09-19
 */
@Api(tags = "后台;更多服务")
@RestController
@RequestMapping("/system/services")
public class SkiMoreServicesController extends BaseController {
    @Resource
    private ISkiMoreServicesService skiMoreServicesService;

    /**
     * 查询更多服务列表
     */
    @ApiOperation(value = "查询更多服务列表")
    @PreAuthorize("@ss.hasPermi('system:services:list')")
    @GetMapping("/list")
    public TableDataInfo list(SkiMoreServices skiMoreServices) {
        startPage();
        List<SkiMoreServices> list = skiMoreServicesService.selectSkiMoreServicesList(skiMoreServices);
        return getDataTable(list);
    }

    /**
     * 导出更多服务列表
     */
    @ApiOperation(value = "导出更多服务列表")
    @PreAuthorize("@ss.hasPermi('system:services:export')")
    @Log(title = "导出更多服务列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SkiMoreServices skiMoreServices) {
        List<SkiMoreServices> list = skiMoreServicesService.selectSkiMoreServicesList(skiMoreServices);
        ExcelUtil<SkiMoreServices> util = new ExcelUtil<SkiMoreServices>(SkiMoreServices.class);
        util.exportExcel(response, list, "更多服务数据");
    }

    /**
     * 获取更多服务详细信息
     */
    @ApiOperation(value = "获取更多服务详细信息")
    @PreAuthorize("@ss.hasPermi('system:services:query')")
    @GetMapping(value = "/{servicesId}")
    public AjaxResult getInfo(@PathVariable("servicesId") String servicesId) {
        return AjaxResult.success(skiMoreServicesService.selectSkiMoreServicesByServicesId(servicesId));
    }

    /**
     * 新增更多服务
     */
    @RepeatSubmit
    @ApiOperation(value = "新增更多服务")
    @PreAuthorize("@ss.hasPermi('system:services:add')")
    @Log(title = "新增更多服务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody @Validated MoreServicesDTO dto) {
        return toAjax(skiMoreServicesService.addMoreServices(dto));
    }

    /**
     * 修改更多服务
     */
    @RepeatSubmit
    @ApiOperation(value = "修改更多服务")
    @PreAuthorize("@ss.hasPermi('system:services:edit')")
    @Log(title = "修改更多服务", businessType = BusinessType.UPDATE)
    @PutMapping("/{moreServicesId}")
    public AjaxResult edit(@PathVariable("moreServicesId")String moreServicesId, @RequestBody @Validated MoreServicesDTO dto) {
        return toAjax(skiMoreServicesService.updateMoreServices(moreServicesId,dto));
    }

    /**
     * 删除更多服务
     */
    @ApiOperation(value = "删除更多服务")
    @PreAuthorize("@ss.hasPermi('system:services:remove')")
    @Log(title = "删除更多服务", businessType = BusinessType.DELETE)
    @DeleteMapping("/{servicesIds}")
    public AjaxResult remove(@PathVariable String[] servicesIds) {
        return toAjax(skiMoreServicesService.deleteSkiMoreServicesByServicesIds(servicesIds));
    }

    @ApiOperation(value = "获取所有的更多服务")
    @GetMapping(value = "/getAll")
    public AjaxResult getAll() {
        return AjaxResult.success(skiMoreServicesService.getAll());
    }
}
